/*
 * @Description:
 * @Version: 2.0
 * @Autor: wangmiao
 * @Date: 2022-07-09 09:48:53
 * @LastEditors: wangmiao
 * @LastEditTime: 2022-08-31 14:37:59
 */
import React from 'react'
import { Route, Routes } from 'react-router-dom' // 引入 react-router-dom
import { Suspense } from 'react'
import { Redirect } from './Redirect'
import { routeProps } from './config'
interface Props {
  route: Array<routeProps>
}
const RouterView: React.FC<Props> = (props) => {
  const { route } = props
  return (
    <Suspense fallback={<div>...Loading</div>}>
      <Routes>
        {route.map((item, index) => (
          <Route key={index} path={item.path} element={item.element}></Route>
        ))}
        <Route path='/' element={<Redirect to='/home' />} />
      </Routes>
    </Suspense>
  )
}

export default RouterView
